<?php
/**
 * 后台管理员登录控制器
 * 13-5-8 下午9:03 
 */
class ManagerController extends Controller{
 
    /**
     * @return array action filters
     */
    public function filters()
    {
        return array(
                'accessControl', // perform access control for CRUD operations
                'postOnly + delete', // we only allow deletion via POST request
        );
    }
    
    /**
     * Specifies the access control rules.
     * This method is used by the 'accessControl' filter.
     * @return array access control rules
     */
    public function accessRules()
    {
        return array(
                array('allow',  // allow all users to perform 'index' and 'view' actions
                        'actions'=>array('login','logout'),
                        'users'=>array('*'),
                ),
                array('allow', // allow authenticated user to perform 'create' and 'update' actions
                        'actions'=>array(),
                        'users'=>array('@'),
                ),
                array('deny',  // deny all users
                        'users'=>array('*'),
                ),
        );
    }
    
   
    /*
     * 实现用户登录
     */
    public function actionLogin(){
        
        //调用模板
        $this ->render('login');
    }
    
    /*
     * 管理员退出系统
     */
    public function actionLogout(){
        //删除session变量
        Yii::app()->session->clear();
        
        //删除服务器session信息
        Yii::app()->session->destroy();
        
        //页面重定向到登录页面
        $this -> redirect('./index.php?r=admin/manager/login');
    }
    
}